﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Northwind;

namespace Northwind.Web
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindOrdersGrid();
        }

        protected void BindOrdersGrid()
        {
            using(var db = new NorthwindEntities())
            {
                var customers = from c in db.Customers
                                orderby c.PostalCode
                                select c;

                this.lbCustomers.Items.Clear();
                this.lbCustomers.Items.Add(new ListItem("Select One"));
                foreach(var customer in customers)
                {
                    this.lbCustomers.Items.Add(new ListItem(customer.CompanyName, customer.CustomerID));
                }

            }
        }
    }
}
